package logic

import (
	"collection_srv/collection"
	"collection_srv/internal/dao"
	"collection_srv/internal/svc"
	"collection_srv/model"
	"context"
	"github.com/zeromicro/go-zero/core/logx"
)

type ThermometerLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewThermometerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ThermometerLogic {
	return &ThermometerLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 体温测试数据
func (l *ThermometerLogic) Thermometer(in *collection.ThermometerRequest) (*collection.ThermometerResponse, error) {
	var result model.ThermometerData // 体温数据表
	//发送者发送消息
	dao.TSendData(uint64(in.DeviceId), uint64(in.UserId), &result)
	//[订阅者] 接收数据
	dao.TMessageCallback(uint64(in.DeviceId), uint64(in.UserId), &result)
	return &collection.ThermometerResponse{Msg: "数据采集成功"}, nil
}
